kmem: don't add __GFP_RECLAIMABLE for KM_VMEM allocations#18107
kmem: don't add __GFP_RECLAIMABLE for KM_VMEM allocations#18107behlendorf merged 1 commit intoopenzfs:masterfrom
Conversation
vmalloc()'d memory is not movable/reclaimable, so __GFP_RECLAIMABLE is not a valid flag, and since 6.19 the kernel warns if you use it. Sponsored-by: https://despairlabs.com/sponsor/ Signed-off-by: Rob Norris <robn@despairlabs.com>
amotin
left a comment
There was a problem hiding this comment.
As I understand, the purpose of __GFP_RECLAIMABLE is to group together allocations of reclaimable memory, so that under pressure shrinker had some higher chances to free contiguous chunks without depending on relocation. I don't think it in any way affects shrinker operation itself. I can speculate that for virtually-mapped memory (unlike physically mapped) fragmentation can be some less of a problem, but it is only a speculation. So if you believe this is right now -- I won't object.
behlendorf
left a comment
There was a problem hiding this comment.
Yeah, it doesn't make sense to set this for vmalloc virtual memory allocations so the warning here is spot on. This looks good.
I have wondered if the kernel's kmem_caches are good-enough these days to just use them directly?
That's a good question. We should already be using them for most things since any kmem cache with small object sizes will be backed by linux slabs. Where we potentially run in to problems is when abd_scatter_enabled=0, in which cache the kmem caches are expected to handled up to 16M objects. The last I checked the kernel slabs simply don't handle this. That said, these days we might be able to impose a similar cap of the kmem caches and wire the ABD code up on the Linux side to its own custom allocator.
vmalloc()'d memory is not movable/reclaimable, so __GFP_RECLAIMABLE is not a valid flag, and since 6.19 the kernel warns if you use it. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes openzfs#18107
vmalloc()'d memory is not movable/reclaimable, so __GFP_RECLAIMABLE is not a valid flag, and since 6.19 the kernel warns if you use it. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes openzfs#18107
vmalloc()'d memory is not movable/reclaimable, so __GFP_RECLAIMABLE is not a valid flag, and since 6.19 the kernel warns if you use it. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes openzfs#18107
vmalloc()'d memory is not movable/reclaimable, so __GFP_RECLAIMABLE is not a valid flag, and since 6.19 the kernel warns if you use it. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes openzfs#18107
vmalloc()'d memory is not movable/reclaimable, so __GFP_RECLAIMABLE is not a valid flag, and since 6.19 the kernel warns if you use it. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #18107
vmalloc()'d memory is not movable/reclaimable, so __GFP_RECLAIMABLE is not a valid flag, and since 6.19 the kernel warns if you use it. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes openzfs#18107
vmalloc()'d memory is not movable/reclaimable, so __GFP_RECLAIMABLE is not a valid flag, and since 6.19 the kernel warns if you use it. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes openzfs#18107
Description
Possibly another GFP flag misuse, now warned about in 6.19.
On the surface its simple: vmalloc'd memory is (apparently) not movable/reclaimable, so
__GFP_RECLAIMABLEis not a valid for it. This commit fixes that.However, I'm concerned that means the shrinker will not call the kmem cache reclaim functions when necessary. I'm not sure either way.
include/linux/gfp_types.hsays:So I wonder if we should be backing kmem caches with memory from reclaimable slabs?
(Or I could just be making up words; I don't know the SPL kmem cache code very well. Though, I have wondered if the kernel's kmem_caches are good-enough these days to just use them directly?)
How Has This Been Tested?
ZTS run against 6.19-rc3 tripped the warning initially. A followup run with this patch passed and didn't warn. That may not be enough to definitely say that it's benign but its a start.
Haven't tested on older kernels; I'll see what CI shakes out first.
Types of changes
Checklist:
Signed-off-by.